package com.zhongli.devplatform.component.im;

import com.tencentyun.TLSSigAPIv2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author WuXiCheng
 * @version 1.0
 */
@Component
public class TLSSigAPIGenerater {

    private static TLSSigAPIGenerater instance;

    @Value("${im.sdkAppId}")
    private Long sdkAppId;

    @Value("${im.secretKey}")
    private String secretKey;

    /**
     * 管理员账户
     */
    @Value("${im.adminName}")
    private String adminName;

    private TLSSigAPIv2 sigAPIv2;

    public String genSig(String userId, long expire){
        if(sigAPIv2 == null){
            sigAPIv2 = new TLSSigAPIv2(sdkAppId, secretKey);
        }

        return sigAPIv2.genSig(userId, expire);
    }

    public Long getSdkAppId() {
        return sdkAppId;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public String getAdminName() {
        return adminName;
    }
}
